<template>
  <div class="header">
    <el-card>
      <div class="head_btn">
        <el-button size="small">管理员列表</el-button>
        <el-button size="small" icon="el-icon-plus">添加管理员</el-button>
      </div>
      <el-table :data="tableData" border size="small" stripe
                :header-cell-style="{textAlign:'center',backgroundColor:'#e4eaec'}"
                :cell-style="{textAlign: 'center'}">
        <el-table-column prop="name" label="ID"/>
        <el-table-column prop="username" label="账号"/>
        <el-table-column prop="classify" label="类别"/>
        <el-table-column prop="createTime" label="添加时间"/>
        <el-table-column label="状态" width="150px">
          <template slot-scope="scope">
            <el-switch v-model="scope.row.switch" active-color="#ffab23" inactive-color="#bababa"/>
          </template>
        </el-table-column>

        <el-table-column label="操作" width="400px">
          <template slot-scope="scope">
            <el-button size="small" type="info" plain>修改</el-button>
            <el-button size="small" type="info" plain @click="dialogDel=true">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>


    <!--删除对话框-->
    <el-dialog :visible.sync="dialogDel" class="del" width="35%">
      <template #title>
        <span>确定要删除该用户组吗？</span>
      </template>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogDel = false" size="small">取消</el-button>
        <el-button @click="dialogDel = false" size="small">确定</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
export default {
  name: 'Dashboard',
  data() {
    return {
      tableData: [
        {username: 'admin', classify: '超级管理员', name: '01', createTime: '2021-12-23 14:30:00', switch: true},
        {username: 'admin', classify: '超级管理员', name: '02', createTime: '2021-12-23 14:30:00', switch: true},
        {username: 'admin', classify: '超级管理员', name: '03', createTime: '2021-12-23 14:30:00', switch: false},
        {username: 'admin', classify: '超级管理员', name: '04', createTime: '2021-12-23 14:30:00', switch: true},
        {username: 'admin', classify: '超级管理员', name: '05', createTime: '2021-12-23 14:30:00', switch: false},
        {username: 'admin', classify: '超级管理员', name: '06', createTime: '2021-12-23 14:30:00', switch: true},
      ],
      dialogDel: false,

    }
  },
  methods: {
    edit(n) {
      this.editForm = n
      this.dialogEdit = true
    },
  },

}
</script>

<style lang="scss" scoped>
.header {
  margin: 30px;

  .head_btn {
    .el-button:nth-child(1) {
      background-color: #3cb3be;
      color: white;
    }

    .el-button:nth-child(2) {
      background-color: #437eb1;
      color: white;
    }
  }

  .el-table {
    margin-top: 15px;

    .el-button:nth-child(1) {
      background-color: #28acb8;
      color: white;
    }

    .el-button:nth-child(2) {
      background-color: #acbac2;
      color: white;
    }

    .el-button:nth-child(3) {
      background-color: #fdad1f;
      color: white;
    }

  }
}

.add .el-dialog {
  .dialog-footer {
    text-align: center;

    .el-button {
      background-color: #2f71a9;
      color: white;
    }
  }
}

.del {
  ::v-deep .el-dialog__body {
    padding: 10px 0;
  }

  .el-dialog {
    .dialog-footer {
      text-align: center;

      .el-button:nth-child(1) {
        background-color: #e3e4e8;
      }

      .el-button:nth-child(2) {
        background-color: #2f71a9;
        color: white;
      }

    }
  }

}

//所有单选
::v-deep .el-radio-group {
  display: flex;
  flex-direction: column;

  .el-radio {
    margin: 7px 0;
  }
}
</style>
